package org.suyafei.strategy;

import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * @author 宿某人
 * @Date: 2021/12/21/2:29 下午
 * @Description:
 */
@Configuration
public class ShardingDBConfig {
    /**
     * 存储数据位置编号
     */
    private static List<String> dbPrefixList = new ArrayList<>();
    static {
        dbPrefixList.add("0");
        dbPrefixList.add("1");
        dbPrefixList.add("a");
    }

    /**
     * 轮询获取
     * @return
     */
    public static String getPollingBPrefix(String code) {

        int hashCode = code.hashCode();

        int index = Math.abs(hashCode) % dbPrefixList.size();
        return dbPrefixList.get(index);
    }

}
